package com.controller.api;

import com.biz.WillingnessResearchBiz;
import com.controller.backend.BaseController;
import com.core.Result;
import com.core.ResultGenerator;
import com.entity.model.WillingnessResearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;

import java.util.List;

/**
 * Created by jc on 2019/11/16.
 */
@RestController("apiWillingnessResearchController")
@RequestMapping("/api/willingnessResearch")
public class WillingnessResearchController extends BaseController<WillingnessResearch> {
    @Autowired
    private WillingnessResearchBiz willingnessResearchBiz;

    //researchType 0:续订意愿调研 1:去哪住你说了算
    //续订意愿调研
    @RequestMapping(value = "/renew")
    public Result renew(@RequestParam Integer customerId, @RequestParam Integer researchRenewal, String contents) {
        if (customerId == null) {
            return ResultGenerator.genFailResult("用户编号不能为空");
        }
        if (researchRenewal == null) {
            return ResultGenerator.genFailResult("续订意愿不能为空");
        }
        WillingnessResearch willingnessResearch = new WillingnessResearch();
        willingnessResearch.setContents(contents);
        willingnessResearch.setCustomerId(customerId);
        willingnessResearch.setResearchType(0);
        willingnessResearch.setResearchRenewal(researchRenewal);
        willingnessResearchBiz.save(willingnessResearch);

        return ResultGenerator.genSuccessResult();
    }


    //researchType 0:续订意愿调研 1:去哪住你说了算
    //去哪住你说了算
    @RequestMapping(value = "/goWhere")
    public Result goWhere(@RequestParam Integer customerId, @RequestParam String researchCity, String contents) {
        if (customerId == null) {
            return ResultGenerator.genFailResult("用户编号不能为空");
        }
        if (researchCity == null) {
            return ResultGenerator.genFailResult("想去的城市不能为空");
        }
        WillingnessResearch willingnessResearch = new WillingnessResearch();
        willingnessResearch.setContents(contents);
        willingnessResearch.setCustomerId(customerId);
        willingnessResearch.setResearchType(1);
        willingnessResearch.setResearchCity(researchCity);
        willingnessResearchBiz.save(willingnessResearch);

        return ResultGenerator.genSuccessResult();
    }
}
